package com.pzl.util;

import android.content.Context;
import android.content.res.Configuration;
import android.location.LocationManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;

public class DeviceUtil
{
    /**
     * 得到设备型号:MI 2S,iphone 5S
     * 
     * @return
     */
    public static String getDeviceMode()
    {
        return android.os.Build.MODEL;
    }
    
    /**
     * 得到设备类型<br>
     * android:phone,tab<br>
     * ios:iPhone,iPod touch
     * 
     * @return
     */
    public static String getDeviceType(Context context)
    {
        Boolean mflag = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
        if (mflag)
        {
            return "tab";
        }
        else
        {
            return "phone";
        }
    }
    
    /**
     * 得到设备EMSI号
     * 
     * @return
     */
    public static String getDeviceId(Context context)
    {
        TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
        String _imsi = tm.getDeviceId();
        if (_imsi != null && !_imsi.equals(""))
        {
            return _imsi;
        }
        return "";
    }
    
    /**
     * 得到设备mac地址
     * 
     * @param context
     * @return
     */
    public static String getMacAddress(Context context)
    {
        WifiManager wifi = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifi.getConnectionInfo();
        return info.getMacAddress();
    }
    
    /**
     * 得到系统名称
     * 
     * @return
     */
    public static String getOSName()
    {
        return System.getProperty("os.name");
    }
    
    /**
     * 得到系统版本号
     * 
     * @return
     */
    public static String getOSVersion()
    {
        return android.os.Build.VERSION.RELEASE;
    }
    
    /**
     * 得到APP版本号
     * 
     * @return
     */
    public static String getAPPVersion(Context mContext)
    {
        
        return null;
    }
    

    
    /**
     * 设备是否打开Gps
     * 
     * @param context
     * @return boolean
     */
    public static boolean isGps(Context context)
    {
        LocationManager mLocationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
        return mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    }
    

    


}
